﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Default.Master" AutoEventWireup="true" CodeBehind="GiaTotSapToi.aspx.cs" Inherits="MasterPageGroupF3.GiaTotSapToiHCM" %>
<%@ Import Namespace="DTO" %>
<%@ Import Namespace="BUS" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <ul class="clsmenuul">
        <li><a href="index.aspx">GIÁ TỐT HÔM NAY </a></li>
        <li><a href="GiaTotGanDay.aspx">GIÁ TỐT GẦN ĐÂY</a> </li>
        <li class="active"><a href="GiaTotSapToi.aspx">GIÁ TỐT SẮP TỚI</a> </li>
         <% if (Session["Provider"] != null)
            {%>
                <li><a href="DangTinKhuyenMai.aspx">ĐĂNG TIN KHUYẾN MÃI</a> </li> 
                 <li><a href="DanhSachDonDatHang.aspx">DS ĐƠN ĐẶT HÀNG</a> </li>
           <%}
            if (Session["UserName"] != null)
            {%>
                <li><a href="LichSuMuaHang.aspx">LỊCH SỬ MUA HÀNG</a> </li> 
                 <li><a href="TinhTrangDonHang.aspx">TÌNH TRẠNG ĐƠN HÀNG</a> </li>
            <%} %>
        <li><a href="ThaoLuan.aspx">THẢO LUẬN</a> </li>
        <li><a href="TroGiup.aspx">TRỢ GIÚP</a> </li>        
    </ul>    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<div class="div_LMainInfo ">
        <div class="div_topLBestPrice">
        </div>
        <div id="divRecentDeal">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
            <ul class='ul_listBestPrice'>
            <% 
                int idCity = 2;  
                int page = 1;                
                if (Request.QueryString["page"] != null)
                {
                    page = int.Parse(Request.QueryString["page"].ToString());
                }
                int nTemp = 6 * page;                                
                PRODUCT[] products = PRODUCTBUS.DanhSachSanPhamSapToiTheoThanhPho(idCity,DateTime.Now.Date);
                int nSp = products.Count();
                if (nTemp > nSp)
                    nTemp = nSp;
                for (int i = 6*(page - 1); i < nTemp; i++)
                {
            %>
                <li class='li_ListBP'>
                    <div class='div_topListBP'>
                    </div>
                    <div class='div_bodyListBP'>
                        <div class='div_bodyLineRound'>
                        </div>
                        <div class='div_infoListBP'>
                            <div class='div_LBodyListBP'>
                                <div class='div_TietKiem'>
                                    <strong class='styleText14'>Tiết Kiệm</strong><br />
                                    <strong class='styleText15'><% Response.Write(products[i].RATE_DECREASE.ToString() + "%"); %></strong></div>
                                <div class='divPrice'>
                                    <span class='styleText17'>Giá trị:<strong class='StyleTextGT lineHorizontal styleText13'>
                                        <%                                         
                                            //String tempPrice = ((int)products[i].PRICE).ToString("#,###");
                                            //tempPrice = tempPrice.Replace(',', '.');
                                            Response.Write(XuLyChuoiTien.ConvertMoney((int)products[i].PRICE)); 
                                        %>
                    </strong></span><div
                                        class='div_VND GTVND'>
                                        <strong class='styleText16'>VND</strong></div>
                                    <br />
                                    <span class='styleText17 spTietKiem'>Tiết kiệm:<strong class='StyleTextGT styleText13'>
                                    <%                                   
                                        int TietKiem = (int)products[i].PRICE * (int)products[i].RATE_DECREASE / 100;
                                        Response.Write(XuLyChuoiTien.ConvertMoney(TietKiem)); 
                                    %>
                                    </strong></span><div
                                        class='div_VND TKVND'>
                                        <strong class='styleText16'>VND</strong></div>
                                </div>
                                <div class='div_infoMoney'>
                                    <div class='div_TextInfoMoney'>
                                        <p class='styleText14'>
                                            <strong>Còn Lại</strong><strong class='strTextVND'>VND</strong></p>
                                        <p class='pGiaTien'>
                                            <strong class='styleText5'>
                                                <%                   
                                                    int ConLai = (int)products[i].PRICE - TietKiem;
                                                    Response.Write(XuLyChuoiTien.ConvertMoney(ConLai)); 
                                                %>
                                            </strong></p>
                                    </div>
                                </div>
                                <p class='color9 styleText9 pWasBuyer'>
                                    <strong>4000</strong></p>
                                <p class='pWasBuyer color9 styleText14'>
                                    Người mua giá tốt</p>
                            </div>
                            <div class='div_RBodyListBP'>
                                <p class='pTextInfoList styleText8'>
                                    <a href="ChiTietSanPham.aspx?idProduct=<% Response.Write(products[i].IDPRODUCT);%>">
                                        <% Response.Write(products[i].SLOGAN);%>
                                        </a></p>
                                <div class='div_imgListBP'>
                                    <a href="ChiTietSanPham.aspx?idProduct=<% Response.Write(products[i].IDPRODUCT);%>">
                                    <%
                                        if (products[i].MAX_NUMBER <= ORDERBUS.SoLuongDaDat(products[i].IDPRODUCT))
                                        {    
                                    %>
                                    <i class='iChayHang'></i>                                    
                                    <%} %>
                                        <img width='229' height='140' src='<% Response.Write("images/product/" + products[i].IDPRODUCT.ToString() + "/1.jpg"); %>' />
                                    </a>
                                </div>
                                <p class='styleText13 pDayCity'>
                                    <%
                                        DateTime NgayDang = Convert.ToDateTime(products[i].TIME_START);                                        
                                        Response.Write(products[i].CITY.NAME + " - " + NgayDang.ToString("dd/MM/yyyy"));                                        
                                    %>
                                </p>
                            </div>
                        </div>
                    </div>
                    <div class='div_bottomListBP'>
                    </div>
                </li>
                <% } 
                   if (nTemp == nSp && nTemp % 2 != 0)
                   {
                %>                                               
                        <li class='li_ListBP'>
                        </li>
                <%} %>
               <div class='div_buttonBP' id='divPaging'>
                   <div class='div_aListPage' id='div_aListPage'>                   
                   <%
                       int SoTrang = nSp / 6;
                       if (nSp % 6 != 0)
                       {
                           SoTrang++;
                       }
                       for (int i = 0; i < SoTrang; i++)
                       {
                           if (page == i + 1)
                           {
                   %>
                                <span><% Response.Write(page.ToString()); %></span>
                         <%}
                           else
                           {
                         %>
                                <a href='<% Response.Write("GiaTotGanDay.aspx?page=" + (i+1).ToString()); %>'><% Response.Write((i + 1).ToString()); %></a>
                         <%}

                       }%>
                   </div>
               </div>
               </ContentTemplate>
            </asp:UpdatePanel>
            
            </ul>
        </div>
    </div>
</asp:Content>
